package luccy.behavior;

import luccy.registry.SingletonCache;
import luccy.util.ClassUtil;

public class SingletonBehavior implements Behavior {

	public SingletonBehavior() {
	}

	public <T> T run(Class<? extends T> clazz, T t) {
		T t_ = SingletonCache.get(clazz);
		if (t_ == null) {
			t_ = ClassUtil.newInstance(clazz);
			SingletonCache.save(clazz, t_);
		}
		return t_;
	}

	public <T> void destroy(Class<? extends T> clazz) {
	}

	public <T> void init(Class<? extends T> clazz) {
	}

}
